package com.wifi.IBackService;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.TextView;

import java.lang.ref.WeakReference;

/**
 * Created by Administrator on 2016/10/8.
 */
class MessageBackReciver extends BroadcastReceiver {
    private WeakReference<TextView> textView;

    public MessageBackReciver(TextView tv) {
        textView = new WeakReference<TextView>(tv);
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        TextView tv = textView.get();
        if (action.equals(ThreadService.HEART_BEAT_ACTION)) {
            if (null != tv) {
                tv.setText("Get a heart heat");
            }
        } else {
            String message = intent.getStringExtra("message");
            tv.setText(message);
        }
    };
}
